import { downLoadXlsx } from '@/utils/downloadfile';
import request from '@/utils/request';

/* *
 *
 * @author whiteshader@163.com
 * @datetime  2021/09/16
 *
 * */
//查询模型列表
export async function getModelList(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/model/list?${queryString}`, {
    // data: params,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//新建模型
export async function addModel(params) {
  return request(`/model/add`, {
    data: params,
    method: 'POST',
  });
}

//编辑模型
export async function updateModel(params) {
  return request(`/model/edit`, {
    data: params,
    method: 'POST',
  });
}

export async function exportModel() {
  return downLoadXlsx(`/model/export`, {}, `model_${new Date().getTime()}.xlsx`);
}
export async function removeModel(params) {
  return request(`/model/remove?ids=${params}`, {
    method: 'POST',
  });
}

export const getDataoverViewList = (params) => {
  const queryString = new URLSearchParams(params).toString();
  return request({
    url: "/radar/dashboard/stat?" + queryString,
    method: "get",
    data: params,
  });
}

export const getListPathByFlightType = (params) => {
  const queryString = new URLSearchParams(params).toString();
  return request({
    url: "/radar/flight/listPathByFlightType?" + queryString,
    method: "get",
    data: params,
  });
}

// 查询字典数据详细
export function getDict(dictType) {
  return request(`/system/dict/data/type/${dictType}`, {
    method: 'GET',
  });
}

// 获取基地信息列表
export async function getAirPlaneLocation(params) {
  return request(`/radar/config/getAirportLocation`, {
    data: params,
    method: 'GET',
  });
}

// 流程图
export const getGraphFlow = () => {
  return request({
    url: "/radar/flowChart/getFlowChart/1",
    method: "get",
  });
};

//版本列表
export async function getBatchModDeviationStatListModal(params) {
  return request({
    url: `/radar/config/listVersionInfo/${params}`,
    method: 'get'
  })
}

//实装匹配给表格的单独使用
export async function getDataQueryDateForTable(params) {
  const queryString = new URLSearchParams(params).toString();
  return request({
    url: `/radar/point/statBySourceId?${queryString}`,
    method: 'get',
    data: params
  })
}

//文件上传
export async function uploadFileVersion(formData) {
  return request(`/file/batch/upload`, {
    method: 'POST',
    data: formData,
    Headers: {'Content-Type': 'multipart/form-data'},
  });
}

// 历史的导出样本
export function exportDownLoadSample(params) {
  return downLoadXlsx(`/radar/point/exportSample`, { params }, `样本列表${new Date().getTime()}.xlsx`);
}

// 航迹关联导出
export function exportDownLoadForm(params) {
  return downLoadXlsx(`/radar/batch/exportRelate`, { params }, `航迹关联列表${new Date().getTime()}.xlsx`);
}

//频率分布
export async function getFlightFrequencyList(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/flight/getFrequencyStat?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//态势实时评估时间点
export async function getSelectInTimePoints(params) {
  return request(`/radar/batch/selectInTimePoints`, {
    method: 'GET',
    data: params,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//查询历史右侧关联数据
export async function getListByUniqueBatchNoList(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/batch/listByUniqueBatchNo?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//初始化关联数据显示
export async function getListAreaStat(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/batch/listAreaStat?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

// 历史的下载
export function exportAreaStat(params) {
  return downLoadXlsx(`/radar/batch/exportAreaStat`, { params }, `Area_${new Date().getTime()}.xlsx`);
}

//区域展示的Modal
export async function getStatAreaHourDeviation(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/batch/statAreaHourDeviation?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//展示航迹
export async function getItineraryMap(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/batch/listLocationRadars?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//航迹检测评估列表
export async function getTestEstimateList(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/testEstimate/listHis?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//点迹检测评估历史数据
export async function getDataQueryDate(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/point/statBySourceId?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//目标探测统计查询
export async function getFlightPathList(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/flight/listStat?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

// 目标类型导出
export function exportDownLoadFlight(params) {
  return downLoadXlsx(`/radar/flight/exportStat`, { params }, `目标探测列表${new Date().getTime()}.xlsx`);
}

// 航迹批次导出
export function exportDownLoadBatch(params) {
  return downLoadXlsx(`/radar/flight/exportLocationBatch`, { params }, `航迹批次${new Date().getTime()}.xlsx`);
}

// 航迹点的导出
export function exportDownLoadRadar(params) {
  return downLoadXlsx(`/radar/batch/exportLocationRadar`, { params }, `航迹点${new Date().getTime()}.xlsx`);
}

//根据类型获取所有的历史航迹
export async function getHistoryPlaneAuxilList(params) {
  // const queryString = new URLSearchParams(params).toString();
  return request(`/radar/batch/selectHistoryTrackByTargetType/${params}`, {
    // data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

export async function getHistoryAuxilList(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/batch/judge?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//目标辅助研判删除
export async function getBatchModDeviationStatDelModal(params) {
  return request(`/model/deleteVersionInfo/${params}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//目标辅助研判列表
export async function getBatchModDeviationStatListModal2(params) {
  return request(`/model/listVersionInfo/${params}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//返回散射统计查询
export async function getIonosphereCoverList(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/coverPower/list?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

//每日航迹批次关联统计
export async function geLlistBatchRelate(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/stat/listBatchRelate?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

// 查询机场信息列表
export async function getAirPlaneList(params) {
  return request(`/radar/config/pageAirPorts`, {
    data: params,
    method: 'POST',
  });
}

// 新增机场信息列表
export async function addAirPlane(params) {
  return request(`/radar/config/addTargetType`, {
    data: params,
    method: 'POST',
  });
}

// 修改机场信息列表
export async function updateAirPlane(params) {
  return request(`/radar/config/editAirPortAndAirPlane`, {
    data: params,
    method: 'POST',
  });
}

// 删除机场信息列表
export async function getAirPlaneDelete(params) {
  return request(`/radar/config/removeAirPortBatch`, {
    data: params,
    method: 'POST',
  });
}

//航线列表
export async function getBatchMatchList(params) {
  return request(`/radar/batch/listBatchMatch`, {
    data: params,
    method: 'POST',
  });
}

//radar/batch/queryLocationRelate
export async function getLocationRelate(params){
  return request({
    url: "/radar/batch/queryLocationRelate",
    method: "get",
    params: params,
  });
}

export async function getRadarBatchList(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/radar/batch/list?${queryString}`, {
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}
